www.mxdraw.com
内容索引主面
前一个向上下一个
IMxDrawCurve::OffsetCurves 方法

曲线偏移

IDL
[helpstring("method OffsetCurves")]
HRESULT OffsetCurves([in] DOUBLE dOffsetDist, [in] IMxDrawPoint* ptOffsetRef, [out] IMxDrawResbuf** aryNewId, [out,retval] VARIANT_BOOL* isOk);
参数 
说明 
[in] DOUBLE dOffsetDist 
偏移距离 
[in] IMxDrawPoint* ptOffsetRef 
偏移方向参考点,曲线向该点所在位置偏移 
[out] IMxDrawResbuf** aryNewId 
返回偏移后新生成的曲线id数组 

成功返回TRUE

例如:C#中调用该函数的例子

    private void OffsetCurves()
    {
        MxDrawUtility mxUtility = new MxDrawUtility();
        object getPt;
        MxDrawEntity ent = mxUtility.GetEntity(out getPt,"选择编移的曲线:");
        if (ent == null)
            return;

        MxDrawCurve curve;
        if(ent is MxDrawCurve)
        {
            curve = (MxDrawCurve)ent;
        }
        else
        {
            MessageBox.Show("实体类型不对");
            return;
        }

        MxDrawPoint getPt1 = (MxDrawPoint)(mxUtility.GetPoint(null, "点取偏移位置:"));

        if (getPt1 == null)
        {
            MessageBox.Show("用户取消..");
            return;
        }

        MxDrawPoint getPt2 = (MxDrawPoint)(mxUtility.GetPoint(getPt1, "点取偏移距离:"));
        if (getPt2 == null)
        {
            MessageBox.Show("用户取消..");
            return;
        }

        Double dis = (getPt1.x - getPt2.x) * (getPt1.x - getPt2.x) + (getPt1.y - getPt2.y) * (getPt1.y - getPt2.y);
        dis = Math.Sqrt(dis);

        object objId;
        if(curve.OffsetCurves(dis, getPt1, out objId) )
        {
            MxDrawResbuf rbId = (MxDrawResbuf)objId;
            MessageBox.Show("偏移生成的曲线个数:" + rbId.Count);
        }
    }

VB6中的调用例程

    Private Sub DoOffCurve()
   Set mxUtility = New MxDrawXLib.MxDrawUtility
   Dim ent As MxDrawXLib.MxDrawEntity
   //选择要偏移的对象
   Set ent = mxUtility.GetEntity(getPt, Chr(13) + Chr(10) + "选择偏移的实体")

   If (ent Is Nothing) Then
        MsgBox "没有选择实体.."
        Exit Sub
   End If

    Dim curve As MxDrawXLib.MxDrawCurve
    If TypeOf ent Is MxDrawXLib.MxDrawCurve Then
        Set curve = ent
    Else
        MsgBox "实体类型不对"
        Exit Sub
    End If

    Dim getPt1 As MxDrawXLib.MxDrawPoint

    Set getPt1 = mxUtility.GetPoint(, Chr(13) + Chr(10) + "点取偏移位置:")

    If (getPt1 Is Nothing) Then
        MsgBox "用户取消.."
        Exit Sub
    End If
    Dim getPt2 As MxDrawXLib.MxDrawPoint

    Set getPt2 = mxUtility.GetPoint(getPt1, Chr(13) + Chr(10) + "点取偏移距离")

    If (getPt2 Is Nothing) Then
        MsgBox "用户取消.."
        Exit Sub
    End If
    Dim dis As Double

    dis = (getPt1.x - getPt2.x) * (getPt1.x - getPt2.x) + (getPt1.y - getPt2.y) * (getPt1.y - getPt2.y)

    dis = Sqr(dis)

    Dim rb  As MxDrawXLib.MxDrawResbuf
    curve.OffsetCurves dis, getPt1, rb

    End Sub
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!